import VueRouter from 'vue-router'

//引入组件
import Index from '../pages'
import Home from '../pages/home/home'
import Login from '../pages/login/login'
import Register from '../pages/register/register'
import Center from '../pages/center/center'
import Messages from '../pages/messages/list'
import Forum from '../pages/forum/list'
import ForumAdd from '../pages/forum/add'
import ForumDetail from '../pages/forum/detail'
import MyForumList from '../pages/forum/myForumList'
import Storeup from '../pages/storeup/list'

import userList from '../pages/user/list'
import userDetail from '../pages/user/detail'
import userAdd from '../pages/user/add'
import courseList from '../pages/course/list'
import courseDetail from '../pages/course/detail'
import courseAdd from '../pages/course/add'
import courseTypeList from '../pages/courseType/list'
import courseTypeDetail from '../pages/courseType/detail'
import courseTypeAdd from '../pages/courseType/add'

import learningProgressList from '../pages/learningProgress/list'
import learningProgressDetail from '../pages/learningProgress/detail'
import syslogList from '../pages/syslog/list'
import syslogDetail from '../pages/syslog/detail'
import syslogAdd from '../pages/syslog/add'
import comment from '../pages/comment/list'

import courseDashboard from '../teacherPages/views/CourseDashboard'
import courseForm from '../teacherPages/views/CourseForm'
import courseReviews from '../teacherPages/views/CourseReviews'


const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}

//配置路由
export default new VueRouter({
	routes:[
		{
      path: '/',
      redirect: '/index/home'
    },
		{
			path: '/index',
			component: Index,
			children:[
				{
					path: 'home',
					component: Home
				},
				{
					path: 'center',
					component: Center,
				},

				{
					path: 'messages',
					component: Messages
				},
				{
					path: 'forum',
					component: Forum
				},
				{
					path: 'forumAdd',
					component: ForumAdd
				},
				{
					path: 'forumDetail',
					component: ForumDetail
				},
				{
					path: 'myForumList',
					component: MyForumList
				},
				{
					path: 'storeup',
					component: Storeup
				},
				{
					path: 'user',
					component: userList
				},
				{
					path: 'userDetail',
					component: userDetail
				},
				{
					path: 'userAdd',
					component: userAdd
				},
				{
					path: 'course',
					component: courseList
				},
				{
					path: 'courseDetail',
					component: courseDetail
				},
				{
					path: 'courseAdd',
					component: courseAdd
				},
				{
					path: 'comment',
					component: comment
				},
				{
					path: 'courseType',
					component: courseTypeList
				},
				{
					path: 'courseTypeDetail',
					component: courseTypeDetail
				},
				{
					path: 'courseTypeAdd',
					component: courseTypeAdd
				},
				{
					path: 'learningProgress',
					component: learningProgressList
				},
				{
					path: 'learningProgressDetail',
					component: learningProgressDetail
				},
				{
					path: 'syslog',
					component: syslogList
				},
				{
					path: 'syslogDetail',
					component: syslogDetail
				},
				{
					path: 'syslogAdd',
					component: syslogAdd
				},
				{
					path: 'courseDashboard',
					component: courseDashboard
				},
				{
					path: 'courseForm',
					component: courseForm
				},
				{
					path: 'courseReviews',
					component: courseReviews
				},
			]
		},
		{
			path: '/login',
			component: Login
		},
		{
			path: '/register',
			component: Register
		},
	]
})
